﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="clr-namespace:Elysium.Parameters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium;component/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type RadioButton}">        
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}"/>
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}"/>
        <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
        <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <BulletDecorator Background="{StaticResource TransparentBrush}"
                                     TextBlock.Foreground="{TemplateBinding Foreground}"
                                     TextBlock.FontFamily="{TemplateBinding FontFamily}"
                                     TextBlock.FontSize="{TemplateBinding FontSize}"
                                     TextBlock.FontWeight="{TemplateBinding FontWeight}"
                                     FlowDirection="{TemplateBinding FlowDirection}"
                                     SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <BulletDecorator.Bullet>
                            <Grid Width="{TemplateBinding params:Bullet.DecoratorSize}" Height="{TemplateBinding params:Bullet.DecoratorSize}">
                                <Ellipse Fill="{TemplateBinding Background}"
                                         Stroke="{TemplateBinding BorderBrush}"
                                         StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessToDoubleConverter}}"/>
                                <Ellipse x:Name="CheckBullet"
                                         Fill="{StaticResource AccentBrush}"
                                         StrokeThickness="0"
                                         Visibility="Collapsed"
                                         HorizontalAlignment="Center" VerticalAlignment="Center"
                                         Width="{TemplateBinding params:Bullet.Size}" Height="{TemplateBinding params:Bullet.Size}">
                                </Ellipse>
                            </Grid>
                        </BulletDecorator.Bullet>
                        <Border Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}">
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              RecognizesAccessKey="True"/>
                        </Border>
                    </BulletDecorator>                    
                    <ControlTemplate.Triggers>                        
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible"/>
                        </Trigger>                        
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="CheckBullet" Property="Ellipse.Fill" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>                        
                    </ControlTemplate.Triggers>                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>        
        <Style.Triggers>            
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource HighlightBrush}"/>
                <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource HighlightBrush}"/>
                <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
                <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource DisabledBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>